// Title:  Replication materials for "Constiuency Size and Evaluations of Government"
// Author: Daniel Bowen, TCNJ
// Date:   August 3rd, 2021	

// Description
These files contain code and data to replicate figures and analyses in the paper using 
survey data publically available from other sources. 

// Files
* Scripts (Stata 15 do files)
	- primary.do: runs all replication analyses for the project
	- cs-history.do: replicates Figures 1, 2, 3, and OA 1
	- region.do: codes states into regions
	- pew97layout.do, pew2001midnov.do, pew2002dec.do, pew2005dec.do, 
	  pew2008april.do, pew2009july.do, pew2010feb.do, pew2011feb.do,
	  pew2012april.do
		: files recode Pew survey data, various years
		  [NOTE: users must download survey data from Pew or through
		   another repository. As of publication, surveys are available:
		1997: https://doi.roper.center/?doi=10.25940/ROPER-31095683
		2001: https://www.pewresearch.org/politics/dataset/mid-november-survey/
		2002: https://www.pewresearch.org/politics/dataset/december-2002-news-interest-index/
		2005: https://doi.roper.center/?doi=10.25940/ROPER-31095855
		2008: https://www.pewresearch.org/politics/dataset/april-2008-political-survey/
		2009: https://www.pewresearch.org/politics/dataset/july-2009-political-media-survey/
		2010: https://www.pewresearch.org/politics/dataset/february-2010-political-survey/
		2011: https://www.pewresearch.org/politics/dataset/february-2011-political-survey/
		2012: https://www.pewresearch.org/politics/dataset/april-2012-values-survey/]

	- cs-recode.do: completes recodes and merges survey and state-level data
	- cs-estimate.do: conducts main analyses in paper and online appendix;
		creates Tables 2, 3,  predictions for Table 4, Fig 5 
	- cs-alt-measures.do: called by cs-estimate.do; replicates Tables OA2-5, 
		creates estimates for Fig OA2
	- cs-alt-legprof.do: called by cs-estimate.do; replicates Table OA6
	- cs-alt-me-graph.do: creates Fig OA2
	- cs-acs-graph.do: uses entropy data to create mini-figures for Fig 7. 
	- cs-mrp.do: conducts MRP analyses, runs models for Table 1, creates Fig. 4 
	- cs-mech.do: conducts causal mechanism analyses; requires NAES 2008 survey data;
		creates Fig. 6., Tables 5 and OA7
		[NOTE: users must download survey data from Annenberg Public Policy Center 
		(restricted): https://www.annenbergpublicpolicycenter.org/2008-naes-telephone-and-online-data-sets/	

	- cs-alt-mech-personal.do: restimates Tables 2 and 3, replacing constituency 
		size with proportion personally acquainted with state legislator from
		the 2008 NAES, replicates Table OA 8.  
	- cs-zip.do: uses zip codes to match Pew respondents to state legislative district;
		makes Tables OA9-12 and Fig OA3.

* Data
	- history.dta: chamber size and population data over time from Dubin 2007, 
		Book of the States, and the U.S. Census Bureau.
	- stateidentifiers.dta: a dataset of state identifying codes.
	- stmerge.dta: state-level covariates collected from a range of sources.
	- entropy.dta: estimates of Theil's entropy and H indices for 
		race, age, education family income, and foreign born status.
		Cleaned data from 2010 ACS 5-year estimates. 
	- stcounts.dta: demographic cells with counts by state for MRP analysis, by year. 
	- zip_county.dta: zip-to-county correspondence file (cleaned; from Missouri Census Data Center)
	- zip_puma.dta:	zip-to-puma correspondence file (cleaned; from Missouri Census Data Center)
	- zip_sldl.dta:	zip-to-state legislative district (lower) correspondence file 
		(cleaned; from Missouri Census Data Center)
	- zip_sldu.dta:	zip-to-state legislative district (upper) correspondence file 
		(cleaned; from Missouri Census Data Center)
	- sler_l_2005.dta: State Legislative Election Returns in 2005 (lower), from Klarner et. al (2013)
	- sler_l_2008.dta: State Legislative Election Returns in 2008 (lower), from Klarner et. al (2013)
	- sler_u_2005.dta: State Legislative Election Returns in 2005 (upper), from Klarner et. al (2013)
	- sler_u_2008.dta: State Legislative Election Returns in 2005 (upper), from Klarner et. al (2013)

// Files Produced
* datasets created (by source do files):
	cs-history.do
		historycoef.dta
	primary.do
		cs-recode.dta
	cs-recode.do
		cs-recode.dta (updated)
	cs-estimate.do
		estimation_resultions.dta
		estimation_results_wgt.dta
		estimation_results_sen.dta
		estimation_results_bicam.dta
	cs-mrp.do
		re_*.dta, re_all_*.dta
		mrp_est.dta
	cs-acs-graph.do
		entropy_*.dta
	cs-mech.do
		stmerge2008.dta
		personal.dta
* graphs created (by source do files):
	cs-history.do
		sl-size.pdf (Fig 1), 
		sl-cs.pdf (Fig OA1), 
		cs-history.pdf (Fig 3), 
		pop_leg.pdf (Fig 2)
	cs-estimate.do
		marginaleffect.pdf (Fig 5)
	cs-alt-me-graph.do
		marginaleffect_altmeasures.pdf (Fig OA2)
	cs-mrp.do
		scatter-mrp-year.pdf (Fig 4)
	cs-acs-graph.do
		H_race.pdf, H_faminc.pdf, H_age.pdf, H_ed.pdf, H_fb.pdf (Fig 7)
	cs-mech.do
		personal.pdf (Fig 6)
	cs-zip.do
		H_firstdiff.pdf (Fig OA3)
* tables created (by source do files):
	cs-estimate.do
		table2_3.txt
	cs-alt-measures.do (called by cs-estimate.do)
		tableOA2_5.txt
		tableOA3_5.txt
		tableOA4_5.txt
	cs-alt-legprof.do (called by cs-estimate.do)
		tableOA6.txt
	cs-mrp.do
		table1.txt
	cs-mech.do
		tableOA7.txt
		table5.txt
	cs-alt-mech-personal.do
		tableOA8.txt
	cs-zip.do
		tableOA9_12.txt

Secondary data sources:

Bowen, Daniel and Greene, Zachary. 2014. "Legislative Professionalism Component Scores, V1.1.1", https://doi.org/10.7910/DVN/27595, Harvard Dataverse, V3, UNF:6:ytWAFEgnSWO4LazQsoDY2Q== [fileUNF]

Caughey, Devin and Christopher Warshaw. "Mass Ideology and Policy Liberalism of American States from 1936-2020", available from http://www.chriswarshaw.com/data/php. 

Council of State Governments. Various Years. The Book of the States. "State Debt Outstanding at End of Fiscal Year, By State."

Council of State Governments. Various Years. The Book of the States. "The Legislators: Numbers, Terms, and Party Affiliations."

Dubin, Michael J. 2007. Party Affiliations in the State Legislatures: A Year by Year Summary, 1796-2006. McFarland & Company.

Klarner, Carl; Berry, William D.; Carsey, Thomas M.; Jewell, Malcolm; Niemi, Richard; Powell, Lynda; and Snyder, James. State Legislative Election Returns (1967-2010). Inter-university Consortium for Political and Social Research [distributor], 2013-01-11. https://doi.org/10.3886/ICPSR34297.v1

Klarner, Carl. 2013. "State Partisan Balance Data, 1937 - 2011", https://doi.org/10.7910/DVN/LZHMG3, Harvard Dataverse, V1.

Ruggles, Steven; Flood, Sarah; Foster, Sophia; Goeken, Ronald; Pacas, Jose; Schouweiler, Megan; and Sobek, Matthew. IPUMS USA: Version 11.0 [dataset]. Minneapolis, MN: IPUMS, 2021. https://doi.org/10.18128/D010.V11.0

Shor, Boris. 2020. "Aggregate State Legislator Shor-McCarty Ideology Data, July 2020 update", https://doi.org/10.7910/DVN/AP54NE, Harvard Dataverse, V1, UNF:6:PPNnE2bgMV3PZ8nP1fJtxg== [fileUNF]

Tausanovitch, Chris and Christopher Warshaw. "Mass Ideology of U.S. Geographies from 2000-2014," available from http://www.chriswarshaw.com/data/php.	

United States Census Bureau. 2000. Census 2000: SF1, SF3. Accessed via American Factfinder. 

United States Census Bureau. 2010. Census 2010: SF1, SF3. Accessed via American Factfinder. 

United States Census Bureau. Various Years. American Community Survey, 5-year estimates. 
